package com.mew.common.util;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 性别枚举类型---Enum--
 * @author SK
 * @since 2019-08-13
 */
public enum GenderType{

    Male(1, "男"),
    Female(2, "女");

    private final static Map<Integer, GenderType> stateMap
            = Arrays.stream(GenderType.values()).collect(Collectors.toMap(GenderType::code, code -> code));

    private int code;
    private String desc;

    GenderType(final int code, final String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

    public static GenderType parse(int code) {
        return stateMap.getOrDefault(code, GenderType.Female);
    }

}
